<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03-axios的介绍与页面配置</title>
    <!-- 这样即可引入axios -->
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.4/axios.js"></script>
</head>
<body>
    <button>GET</button>
    <button>POST</button>
    <button>PUT</button>
    <button>DELETE</button>

    <script>
        let btns = document.querySelectorAll('button');
        
        btns[0].onclick = ()=>{
            axios({
                // 请求类型
                method:'GET',
                // url
                url:'http://localhost:10086/hotWebs/getAllHotWebs',

            }).then(res=>console.log(res))
        }

        btns[1].onclick = ()=>{
            axios({
                method:"POST",
                url:'http://localhost:10086/demo/demoPost',
                data:{
                    title:'test',
                    author:'mks'
                }
            }).then(res=>console.log(res))
        }

        btns[2].onclick = ()=>{
            axios({
                method:"PUT",
                url:'http://localhost:10086/demo/demoPut',
                data:{
                    title:'test',
                    author:'mks'
                }
            }).then(res=>console.log(res))
        }

        btns[3].onclick = ()=>{
            axios({
                method:"DELETE",
                url:'http://localhost:10086/demo/demoDelete',
                data:{
                    id:'3'
                }
            }).then(res=>console.log(res))
        }
    </script>
</body>
</html>